﻿using System.Threading.Tasks;

namespace WpfAGVSystem.Model
{
    public partial class AGVStateServer
    {
        public bool SwitchMap(ushort name) 
        {
            try
            {
                mod.master.WriteSingleRegister(1,28, name);
                return true;
            }
            catch (System.Exception ex)
            {
                return false;
            }
        }
        public bool HighlevelDo1()
        {
            try
            {
                return mod.WriteSingleCoil(60+1, true);
            }
            catch(System.Exception ex)
            {
                return false;
            }
        }
        //升
        public bool HighlevelDo1false()
        {
            try
            {
              return  mod.WriteSingleCoil((ushort)(60+1 - 40), true);
            }
            catch (System.Exception ex)
            {
                return false;
            }
        }
        /// <summary>
        /// 设置Do2 高电平为true 地牛货叉下降
        /// </summary>
        public bool HighlevelDo2()
        {
            try
            {
                return mod.WriteSingleCoil(61+2, true);
            }
            catch (System.Exception ex)
            {
                return false;
            }
        }
        public bool HighlevelDo2false()
        {
            try
            {
              return  mod.WriteSingleCoil((ushort)(61+2 - 40), true);
            }
            catch (System.Exception ex)
            {
                return false;
            }
        }
        /// <summary>
        /// 确认定位正确
        /// </summary>
        public bool AGVConfirm()
        {
            try
            {
                return mod.WriteSingleCoil(2, true);
            }
            catch (System.Exception ex)
            {
                return false;
            }
        }
        /// <summary>
        /// 暂停导航
        /// </summary>
        public bool AGVStop()
        {
            try
            {
                return mod.WriteSingleCoil(3, true);
            }
            catch (System.Exception ex)
            {
                return false;
            }
        }
        /// <summary>
        /// 继续导航
        /// </summary>
        public bool Continue()
        {
            try
            {
                return mod.WriteSingleCoil(4, true);
            }
            catch (System.Exception ex)
            {
                return false;
            }
        }
        /// <summary>
        /// 取消导航
        /// </summary>
        public bool Cancel()
        {
            try
            {
                return mod.WriteSingleCoil(5, true);
            }
            catch (System.Exception ex)
            {
                return false;
            }
        }
        


    }
}